package MapHomeWork.fifth;

import java.util.Scanner;
import java.util.Set;

public class TestStudent {
    public static void main(String[] args) {
        System.out.println("--------学生管理系统--------");
        System.out.println("1.增加学生信息");
        System.out.println("2.根据学号删除学生");
        System.out.println("3.根据学号修改学生");
        System.out.println("4.根据姓名模糊修改学生");
        System.out.println("0.退出系统");
            Scanner scanner = new Scanner(System.in);
            int num = scanner.nextInt();
            switch (num) {
                case 1:
                    System.out.println("请输入学生学号：");
                    int sId = scanner.nextInt();
                    System.out.println("请输入学生姓名：");
                    String name = scanner.next();
                    System.out.println("请输入学生年龄：");
                    int age = scanner.nextInt();
                    StudentBusiness.addStudent(new Student(sId, name, age));
                    break;
                case 2:
                    System.out.println("请输入要删除学生的学号：");
                    int sid = scanner.nextInt();
                    StudentBusiness.deleteStudent(sid);
                    break;
                case 3:
                    System.out.println("请输入要修改的学生学号：");
                    int s = scanner.nextInt();
                    System.out.println("请输入要修改的学生姓名：");
                    String Name = scanner.next();
                    System.out.println("请输入要修改的学生年龄：");
                    int Age = scanner.nextInt();
                    StudentBusiness.updateStudent(new Student(s, Name, Age));
                    break;
                case 4:
                    System.out.println("请输入要查询的学生姓名：");
                    String sName = scanner.next();
                    Set<Student> studentSet = StudentBusiness.findByName(sName);
                    System.out.println("学号\t姓名\t年龄");
                    for (Student student : studentSet) {
                        System.out.println(student.getsId() + "\t" + student.getsName() + "\t" + student.getAge());
                    }
                    break;
                case 0:
                    StudentBusiness.exit();
                    break;
                default:
                    System.out.println("错误");
                    break;
            }

    }
}
